﻿Public Class SOLICITACAO

    Private Sub SOLICITACAO_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.SOLICITACAOTableAdapter.Fill(Me.SOLICITACAODataSet.SOLICITACAO)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.SOLICITACAOTableAdapter.Fill(Me.SOLICITACAODATASET.SOLICITACAO)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If CEDENTETextBox.Text = "" Then
            MsgBox("FAVOR INFORMAR O CEDENTE", MsgBoxStyle.Information, "ATENÇÃO")
        Else
            SOLICITACAOTableAdapter.FillByCEDENTE(SOLICITACAODATASET.SOLICITACAO, CEDENTETextBox.Text)
        End If
    End Sub

    Private Sub PRIMEIRO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PRIMEIRO.Click
        SOLICITACAOBindingSource.MoveFirst()
    End Sub

    Private Sub VOLTAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles VOLTAR.Click
        SOLICITACAOBindingSource.MovePrevious()
    End Sub

    Private Sub NOVO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NOVO.Click
        SOLICITACAOBindingSource.AddNew()
        CEDENTETextBox.Focus()
    End Sub

    Private Sub SALVAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SALVAR.Click
        Try
            ULTALTEMaskedTextBox.Text = DateValue(Now)
            Me.Validate()
            SOLICITACAOBindingSource.EndEdit()
            TableAdapterManager.UpdateAll(SOLICITACAODataSet)
        Catch EX As Exception
            MsgBox("ERRO NA ATUALIZAÇÃO DOS DADOS " & EX.ToString)
        End Try
    End Sub

    Private Sub DELETAR_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DELETAR.Click
        Try
            Me.Validate()
            SOLICITACAOBindingSource.RemoveCurrent()
            SOLICITACAOTableAdapter.Update(SOLICITACAODataSet.SOLICITACAO)
        Catch EX As Exception
            MsgBox("ERRO NA REMOÇÃO DOS DADOS " & EX.ToString)
        End Try
    End Sub

    Private Sub FRENTE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FRENTE.Click
        SOLICITACAOBindingSource.MoveNext()
    End Sub

    Private Sub ULTIMO_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ULTIMO.Click
        SOLICITACAOBindingSource.MoveLast()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ULTALTEMaskedTextBox.Text = "  /  /" Then
            MsgBox("FAVOR INFORMAR A DATA PARA CONSULTA", MsgBoxStyle.Information, "ATENÇÃO")
        Else
            SOLICITACAOTableAdapter.FillByULTIMA(SOLICITACAODATASET.SOLICITACAO, ULTALTEMaskedTextBox.Text)
        End If
    End Sub
    Private Sub SOLICITACAODataGridView_DataBindingComplete1(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewBindingCompleteEventArgs) Handles SOLICITACAODataGridView.DataBindingComplete
        Try
            For intx As System.Int32 = 0 To SOLICITACAODataGridView.Rows.Count - 1
                Dim COROBS As System.String = SOLICITACAODataGridView.Rows(intx).Cells("DataGridViewTextBoxColumn20").Value.ToString
                If InStr(COROBS, "*") = 1 Then
                    SOLICITACAODataGridView.Rows(intx).DefaultCellStyle.BackColor = Color.DarkViolet
                End If
            Next
        Catch EX As Exception
            MsgBox("ERRO AO COLORIR LINHAS " & EX.ToString)
        End Try
    End Sub
End Class